import axios from 'axios';
import { setCookie } from '../../tools/util'

export function loginIn(){
    
    
    var params ={
        account: $('#login-account').val(),
        password: $('#login-password').val()
    }
    axios.get('/login', {
        params: params
    })
    .then(function(response){
        var req = response.data;
        switch (req.code) {
            case 200 : 
                setCookie('u_name', params.account, 30);
                setCookie('u_pw', params.password, 30);
                window.location = '/book';
                break;
            case 400 :
                $('#login-error').show();
                break;
        }
    })
    .catch(function(error){
        alert('系统出错');
    })

}
